import {createRouter, createWebHashHistory} from 'vue-router'
import routes from "./routes";
import {initMenu} from "../utils/menus";
import store from "../store";


const router = createRouter({
    history: createWebHashHistory(),
    routes
})

router.beforeEach((to, from, next) => {
    if (window.sessionStorage.getItem('tokenStr')) {
        initMenu(router, store);
        next();
    } else {
        if (to.path === '/') {
            next();
        }
    }
})

export default router
